home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ9110.ZIP
/
STRING.ZIP
/
STRIREM.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-30
|
652b
|
30 lines
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <string.hpp>
String &String::remove(int pos, int count)
{
if (count <= 0 || pos >= length())
return *this;
if (count > length()-pos) count = length()-pos;
int nl = length()-count;
srep *p = 0;
if (nl) {
p = new(nl) srep(nl);
if (!p) {
errno = ENOMEM;
return *this;
}
memmove(p->body,body(),pos);
memmove(p->body+pos,body()+pos+count,nl-pos);
}
if (rp) {
if (--rp->refs < 1)
delete rp;
}
rp = p;
rp->refs++;
return *this;
}